home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 436_01 / indecl.h < prev    next >
Encoding:
Text File  |  1994-10-07  |  10.5 KB  |  274 lines

  1. /*************************************************************************
  2.     Header file:  INDECL.H
  3.  
  4.     Contains prototypes and descriptions for externally visible
  5.     (public) routines in INCON.LIB  See the file INCON.DOC for
  6.     more information on setting parameters, editing input fields,
  7.     and so on.  The routines declared here may be called directly
  8.     from programs that link INCON.LIB
  9.  
  10.     Compiler:  Borland Turbo C 2.01
  11.  
  12.     INCON source files and the object and library files created from
  13.     them are:
  14.         Copyright (c) 1993-94, Richard Zigler.
  15.     You may freely distribute unmodified source, object, and library
  16.     files, and incorporate them into your own non-commercial software,
  17.     provided that this paragraph and the program name and copyright
  18.     strings defined in INCON.C are included in all copies.
  19. *************************************************************************/
  20.  
  21. /*************************************************************************
  22.     INCON -- Format user input under program control.
  23.  
  24.     Parameters
  25.     ----------
  26.     MBLOCK far *        Far pointer to message block.
  27.  
  28.     The message block may be addressed as either a structure or an
  29.     array of unsigned integers.  See the header file INDEFS.H for
  30.     the data declarations.  See the file INCON.DOC for an extended
  31.     discussion of all parameters.  The message block is laid out as
  32.     follows:
  33.  
  34.     +-------------------------------------------------------------------+
  35.     |            Offset        Low Byte  |  High Byte                   |
  36.     |                        +-----------------------+                  |
  37.     |              0         |         BufOff        |                  |
  38.     |                        |-----------------------|                  |
  39.     |              1         |         BufSeg        |                  |
  40.     |                        |-----------------------|                  |
  41.     |              2         |         KeyOff        |                  |
  42.     |                        |-----------------------|                  |
  43.     |              3         |         KeySeg        |                  |
  44.     |                        |-----------------------|                  |
  45.     |              4         |         Flags         |                  |
  46.     |                        |-----------+-----------|                  |
  47.     |              5         |   Width   |   Prec    |                  |
  48.     |                        |-----------+-----------|                  |
  49.     |              6         |  Visible  |   Attr    |                  |
  50.     |                        |-----------+-----------|                  |
  51.     |              7         |   Fill    |   Pad     |                  |
  52.     |                        +-----------+-----------+                  |
  53.     +-------------------------------------------------------------------+
  54.  
  55.     WORD BufOff        Offset address of input/output buffer.
  56.  
  57.     WORD BufSeg        Segment address of input/output buffer.
  58.  
  59.     WORD KeyOff        Offset address of extended-key list.
  60.  
  61.     WORD KeySeg        Segment address of extended─key list.
  62.  
  63.     WORD Flags        Flags that modify INCON's behavior.  They are
  64.                         declared separately as the union of an unsigned
  65.                         integer and a bit-field, and are laid out as follows:
  66.  
  67.     +-------------------------------------------------------------------+
  68.     | Bit:   15        14  13  12     11     10       9          8      |
  69.     |         |          \  | /         \   /         |          |      |
  70.     |       Debug         Type         Justify      Strip     Message   |
  71.     |       -------   -------------   ----------   -------   ---------  |
  72.     |       0 = No    0 = Alpha       0 = None     0 = No     0 = No    |
  73.     |       1 = Yes   1 = Uppercase   1 = Left     1 = Yes    1 = Yes   |
  74.     |                 2 = Integer     2 = Center                        |
  75.     |                 3 = Float       3 = Right                         |
  76.     |                 4 = Mixed                                         |
  77.     |                                                                   |
  78.     | Bit:    7      6       5       4      3      2      1      0      |
  79.     |         |      |       |       |      |      |      |      |      |
  80.     |        Sign Display Confirm Delimit xKeys  Scroll  Hide Template  |
  81.     |        ---- ------- ------- ------- ----- -------- ---- --------  |
  82.     |                       For all:  0 = No / 1 = Yes                  |
  83.     +-------------------------------------------------------------------+
  84.  
  85.     BYTE Width        The maximum number of characters allowed
  86.                         in the input field.
  87.  
  88.     BYTE Prec        For alpha and integer fields:  the minimum number
  89.                         of characters the user must enter into the input
  90.                         field.
  91.                         For floating─point fields:  the number of digits to
  92.                         the right of the decimal point.
  93.  
  94.     BYTE Visible    Used in conjunction with the Scroll flag; specifies
  95.                         the length of the displayed portion of the input
  96.                         field.
  97.  
  98.     BYTE Attr        Input field colors, specified as a standard DOS
  99.                         attribute byte.
  100.  
  101.     BYTE Fill        The character to display in unoccupied areas of the
  102.                         input field, as a visual guide to the user.  Defaults
  103.                         to the space if the quantity specified is less than
  104.                         ASCII 32.
  105.  
  106.     BYTE Pad            For alpha and integer fields:  the character used
  107.                         to fill leading or trailing spaces in a justified
  108.                         output string.  Defaults to the space if the
  109.                         quantity specified is less than ASCII 32.
  110.  
  111.     Return
  112.     ------
  113.     INCON returns a short integer that indicates the status of the
  114.     input operation.  Only error returns have the high bit set.
  115.  
  116.          0:    Input accepted; no error.
  117.         -1:    User input error.
  118.         27:    The user pressed [Esc] to cancel the input operation.
  119.         74:    The user pressed [Keypad -] or [Keypad +] to end input
  120.         78:     (see INCON.DOC for complete information).
  121.         ##:    Extended─key code.
  122.  
  123.     Run-Time Errors
  124.     ---------------
  125.     Run─time errors are those made by the programmer, as opposed to
  126.     input errors made by the user, which are handled by the calling
  127.     routine.  A run-time error may also occur if INCON can't find
  128.     enough memory for its internal buffers.  In response to run-time
  129.     errors, INCON beeps and prints a message in an onscreen "message
  130.     bar" that takes its colors from the Attr parameter.  It then waits
  131.     for a keypress before returning an error code to the calling
  132.     routine.  The error code returned is the error number from the
  133.     list below, minus 32768 (the high bit is set).  Run─time error
  134.     messages have the form
  135.  
  136.         INCON error #:  message.  Press any key...
  137.  
  138.     where # and message are one of those listed below.
  139.  
  140.         Error #        Message
  141.         -------        -----------------------------------------------------
  142.             1            Invalid field precision
  143.             2            Invalid field width or scroll visible length
  144.             3            Default input string too long
  145.             4            Type float; precision is invalid
  146.             5            Type float; no room for decimal point
  147.             6            Fill character appears in template
  148.             7            Invalid template
  149.             8            Insufficient memory for internal buffers
  150.             9            Input/output buffer pointer is NULL
  151.  
  152.     Run-time error messages may be turned off by clearing the Message
  153.     flag.  See INCON.DOC for more information.
  154.  
  155.     INCON cannot check the length of the input/output buffer against
  156.     Width.  It is the responsibility of the calling routine to insure
  157.     that the buffer is large enough to hold the requested number of
  158.     characters, plus the null terminator.
  159. *************************************************************************/
  160.  
  161. short pascal InCon( MBLOCK far * );                                /* INCON.C        */
  162.  
  163. /*************************************************************************
  164.     Cursor handling.  Call with OFF argument prior to ON, and with
  165.     SAVE prior to RESTORE.
  166.  
  167.     Parameters
  168.     ----------
  169.     short Switch        Service required.
  170.  
  171.     Return
  172.     ------
  173.     None
  174. *************************************************************************/
  175.  
  176. void pascal Cursor( short CurSwitch );                            /* INUTIL.C        */
  177.  
  178. /*************************************************************************
  179.     GetCursor() -- Get absolute screen coordinates.
  180.  
  181.     Parameters
  182.     ----------
  183.     short *Row            Screen row (0-24).
  184.     short *Col            Screen column (0-79).
  185.  
  186.     Return
  187.     ------
  188.     None
  189. *************************************************************************/
  190.  
  191. void pascal GetCursor( short * Row, short * Col );            /* INUTIL.C        */
  192.  
  193. /*************************************************************************
  194.     GetVideoAttr -- Get video attribute at cursor.
  195.  
  196.     Parameters
  197.     ----------
  198.     none
  199.  
  200.     Return
  201.     ------
  202.     int Attribute        Current video attribute.
  203. *************************************************************************/
  204.  
  205. int pascal GetVideoAttr( void );                                    /* INUTIL.C        */
  206.  
  207. /*************************************************************************
  208.     PutCursor -- Place cursor at Row and Col.
  209.  
  210.     Parameters
  211.     ----------
  212.     short Row            Screen row (0-24).
  213.     short Col            Screen column (0-79).
  214.  
  215.     Return
  216.     ------
  217.     None
  218. *************************************************************************/
  219.  
  220. void pascal PutCursor( short, short );                            /* INUTIL.C        */
  221.  
  222. /*************************************************************************
  223.     WordLeft -- Scan string left from current position to previous
  224.     occurrence of search character.
  225.  
  226.     Parameters
  227.     ----------
  228.     int CurPos            Current position within String.
  229.     char far *String    String to scan.
  230.     char SearchChar    Quit scan at this character.
  231.  
  232.     Return
  233.     ------
  234.     int CurPos            Pointer to character following SearchChar.
  235. *************************************************************************/
  236.  
  237. int pascal WordLeft( int, char far *, char );                /* INUTIL.C        */
  238.  
  239. /*************************************************************************
  240.     WordRight -- This operation is the mirror image of WordLeft();
  241.     scans right to next occurrence of SearchChar.
  242.  
  243.     Parameters
  244.     ----------
  245.     int CurPos            Current position within String.
  246.     char far *String    String to scan.
  247.     char SearchChar    Quit scan at this character.
  248.  
  249.     Return
  250.     ------
  251.     int CurPos            Pointer to character following SearchChar.
  252. *************************************************************************/
  253.  
  254. int pascal WordRight( int, char far *, char );                /* INUTIL.C        */
  255.  
  256. /*************************************************************************
  257.     WriteMany -- Write character and attribute Num times at current
  258.     cursor position; the cursor is not moved.
  259.  
  260.     Parameters
  261.     ----------
  262.     BYTE Chr                Character to write.
  263.     int Attr                Video attribute.
  264.     int Num                Number of times to write Chr.
  265.  
  266.     Return
  267.     ------
  268.     None
  269. *************************************************************************/
  270.  
  271. void pascal WriteMany( BYTE, int, int );                        /* INUTIL.C        */
  272.  
  273. /**** EOF:  INDECL.H ****/
  274.